<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /*
            绝对定位position: absolute;
            top
            left
            right
            bottom

            绝对定位的元素，移动位置，相对于已定位的父元素进行移动
            如果最上级父元素没有定位，那么父级元素为html(文档)
        */

        /* 如何让元素垂直居中 */
        .parent {
            width: 500px;
            height: 500px;
            background: red;
            margin: 100px auto;
            position: relative;
        }

        .child {
            width: 50px;
            height: 50px;
            background: blue;
            position: absolute;
            top: 50%;
            /* left: 50%; */
            left: 0;
            margin-top: -25px;
            /* margin-left: -25px; */
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="child"></div>
    </div>

</body>
</html>